<?php
	class Hotels {
		static function getHotelDestination($slug){
			$sql = @mysql_query("SELECT
						destinations.id AS destination_id,
						destinations.destination_name,
						hotels.id,
						hotels.agoda_id,
						hotels.hotel_name,
						hotels.hotel_slug,
						hotels.photo1,
						hotels.addressline1,
						hotels.zipcode,
						hotels.star_rating,
						hotels.overview,
						hotels.url,
						hotels.rates_from,
						hotels.rates_currency,
						hotels.number_of_reviews,
						hotels.rating_average
						FROM
						destinations
						Inner Join hotels ON destinations.id = hotels.destination_id
						WHERE
						destinations.slug = '$slug'
						LIMIT 0, 20
			");
			
			return $sql;
		}
		
		static function getStarImg($val){
			switch($val){
				case 1:
					$img = BASEURL."img/misc/stars/star_1.png";
				break;
				case 2:
					$img = "img/misc/stars/star_2.png";
				break;
				case 3:
					$img = "img/misc/stars/star_3.png";
				break;
				case 4:
					$img = "img/misc/stars/star_4.png";
				break;
				case 5:
					$img = "img/misc/stars/star_5.png";
				break;
				case 2.5:
					$img = "img/misc/stars/star_2_5.png";
				break;	
				case 3.5:
					$img = "img/misc/stars/star_3_5.png";
				break;	
				case 4.5:
					$img = "img/misc/stars/star_4_5.png";
				break;					
			}
			
			return $img;
		}
		
		static function limitStringOverview($string, $limit){
			$newString = "";
			$word = explode(' ',$string);
			if(count($word) > $limit){
				for($i=0; $i<=$limit; $i++){
					if($i!=0){
						$newString .= " ";
					}
					$newString .= $word[$i];
				}
				$newString = $newString.' ...';
			} else {
				$newString = $string;
			}
			
			return $newString;
		}
		
		static function getHotelDetail($slug){
			$sql = @mysql_query("SELECT
						destinations.id AS destination_id,
						destinations.destination_name,
						destinations.slug,
						hotels.id AS hotel_id,
						hotels.agoda_id,
						hotels.hotel_name,
						hotels.hotel_slug,
						hotels.addressline1,
						hotels.zipcode,
						hotels.star_rating,
						hotels.longitude,
						hotels.latitude,
						hotels.url,
						hotels.checkin,
						hotels.checkout,
						hotels.numberrooms,
						hotels.numberfloors,
						hotels.yearopened,
						hotels.yearrenovated,
						hotels.photo1,
						hotels.photo2,
						hotels.photo3,
						hotels.photo4,
						hotels.photo5,
						hotels.overview,
						hotels.rates_from,
						hotels.rates_currency,
						hotels.number_of_reviews,
						hotels.rating_average
						FROM
						hotels
						Inner Join destinations ON hotels.destination_id = destinations.id
						WHERE
						hotels.hotel_slug = '$slug'
			");
			
			$hotels = @mysql_fetch_array($sql);
			
			return $hotels;
		}
	}
?>